import cv2
import numpy as np

img = np.zeros((480, 640, 3), np.uint8)

# 分割通道
b, g, r = cv2.split(img)

b[10:100, 10:100] = 255
g[10:100, 10:100] = 255

# 合并通道
img2 = cv2.merge((b, g, r))

cv2.imshow('img', np.hstack((b, g, r)))
cv2.imshow('img2', np.hstack((img, img2)))

cv2.waitKey(0)
cv2.destroyAllWindows()
